package com.market.plus.core.dao.jpa;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.market.plus.core.dao.TribeDao;
import com.market.plus.core.domain.News;
import com.market.plus.core.domain.Tribe;

@Repository("tribeDao")
public class JpaTribeDao extends JpaGenericDao<Tribe> implements TribeDao {

   public JpaTribeDao() {
      super(Tribe.class);
   }

   @SuppressWarnings("unchecked")
   public Tribe findByGUID(String guid) {
      Map<String, Object> params = new HashMap<String, Object>();
      params.put(Tribe.PARA_GUID, guid);
      List<Tribe> tribes = this.findByNamedQueryAndNamedParams(Tribe.FIND_GUID, params);
      if (tribes.size() > 0) {
         return tribes.get(0);
      }
      return null;
   }

   @SuppressWarnings("unchecked")
   public List<News> getNews(String guid) {
      Map<String, Object> params = new HashMap<String, Object>();
      params.put(Tribe.PARA_GUID, guid);
      List<News> news = this.findByNamedQueryAndNamedParams(Tribe.FIND_NEWS, params);
      return news;
   }
}
